outsideworkers <- east_lodes %>%
filter(w_county %in% eastfips == F)
Below I show the percentile calculations for Virginia counties based on the number of Eastern Shore area residents who are employed in that county. These calculations do not include the number of Eastern Shore area residents who are employed within the Eastern Shore region. For example, the number of people who live in Albemarle County and commute to Eastern Shore City are not reflected in this calculations. The bar graphs show the most common and least common work-destination counties for Eastern Shore area residents who work outside of the Eastern Shore area.
quantile(na.omit(outsideworkers$commuters), probs = seq(0, 1, by= 0.05))
## 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 60% 65% 70% 75%
## 1 1 2 4 4 6 7 9 12 14 16 19 22 26 30 34
## 80% 85% 90% 95% 100%
## 46 73 135 260 568
Bottom 25th percentile (the least common work-destinations for Eastern Shore area residents)
# Counties that are in the bottom 25th percentile in terms of number of Eastern Shore region residents commuters.
outsideworkers25 <- outsideworkers[which(outsideworkers$commuters <= quantile(na.omit(outsideworkers$commuters), probs = 0.25)),]
ggplot(outsideworkers25, aes(x = NAME, y = commuters))+
geom_bar(stat = 'identity', width = 0.5) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = "County", y = "Eastern Shore area resident commuters")
Top 75th percentile (the most common work-destinations for Eastern Shore area residents who work outside the Eastern Shore region)
# Counties that are in the top 75th percentile in terms of number of Eastern Shore region residents commuters.
outsideworkers75 <- outsideworkers[which(outsideworkers$commuters >= quantile(na.omit(outsideworkers$commuters), probs = 0.75)),]
ggplot(outsideworkers75, aes(x = NAME, y = commuters))+
geom_bar(stat = 'identity', width = 0.5) +
theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
labs(x = "County", y = "Eastern Shore area resident commuters")
The map offers another way to visualize where Eastern Shore area residents who work outside the Eastern Shore region are commuting most often. The counts of Eastern Shore area residents who commute to work within the Eastern Shore region are excluded from the legend so as to limit the range and allow for easier discrimination between the surrounding counties, but the number of commuters to each of the localities in the Eastern Shore region is available by clicking on the locality.
eastlodesmap <- east_lodes
eastlodesmap$commuters <- ifelse(eastlodesmap$w_county %in% eastfips, NA, eastlodesmap$commuters)
pal <- colorNumeric("plasma", reverse = TRUE, na.color = "lightgray", domain = eastlodesmap$commuters)
leaflet(east_lodes) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = eastlodesmap,
fillColor = ~pal(commuters),
weight = 1,
opacity = 1,
color = "white",
fillOpacity = 0.6,
highlight = highlightOptions(
weight = 1, fillOpacity = 0.8, bringToFront = T
),
popup = paste0("County: ", eastlodesmap$NAME, "<br>",
"Number of commuters: ", east_lodes$commuters)) %>%
addLegend("bottomright", pal = pal, values = eastlodesmap$commuters,
title = "Number of Eastern Shore <br> region commuters", opacity = 0.7)